#!/bin/sh
# PCP QA Test No. 1991
# Exercise various pcp-netstat(1) command options.
#
# Copyright (c) 2023 Oracle and/or its affiliates.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#

seq=`basename $0`
echo "QA output created by $seq"

. ./common.python

status=1        # failure is the default!
trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15

pcp_netstat="$PCP_BINADM_DIR/pcp-netstat"
test -x $pcp_netstat || _notrun "No pcp-netstat(1) installed"
pcp_netstat="$python $pcp_netstat"

# real QA test starts here
echo && echo pcp-netstat output : Display default output
PCP_ARCHIVE="archives/pcp-netstat" PCP_HOSTZONE=1 PCP_ORIGIN=1 $pcp_netstat -s 2

archive_first="-a archives/pcp-netstat -z -O +1"

echo && echo pcp-netstat output : Display output of all the network protocol statistics
pcp $archive_first netstat --statistics -s 2

echo && echo pcp-netstat output : Display output when filtered IP protocol
pcp $archive_first netstat -s 2 -p IP

echo && echo pcp-netstat output : Display output when filtered TCP protocol
pcp $archive_first netstat -s 2 -p TCP

echo && echo pcp-netstat output : Display output when filtered UDP protocol
pcp $archive_first netstat -s 2 -p UDP

echo && echo pcp-netstat output : Display output when filtered ICMP protocol
pcp $archive_first netstat -s 2 -p ICMP

echo && echo pcp-netstat output : Display output when asked for interface statistics
pcp $archive_first netstat -s 2 -i


status=0
exit
